package team18.yuejian.Model;

import android.app.DownloadManager;

import java.util.List;
import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import team18.yuejian.RetrofitListener;
import team18.yuejian.Server.MineService;
import team18.yuejian.Server.ShowPicService;
import team18.yuejian.bean.NoteBean;
import team18.yuejian.bean.PicBean;
import team18.yuejian.bean.PicDeteilBean;
import team18.yuejian.bean.ReviewBean;

public class ShowPicModel extends RetrofitModel {
    private String url;
    private ShowPicService service;
    private Retrofit retrofit;
    private RetrofitModel retrofitModel;

    public ShowPicModel(){
        retrofitModel = new RetrofitModel();
        url = retrofitModel.getBaseUrl();
        retrofit = new Retrofit.Builder()
                .baseUrl(url)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        service = retrofit.create(ShowPicService.class);
    }

    public void GetShowPicList(final RetrofitListener<List<PicBean>> listener){
        Call<List<PicBean>> call = service.PicList();
        bindCallback(call,listener,null,1);
    }

    public void AddShowPic(Map<String, RequestBody> requestBodyMap, MultipartBody.Part showPic,final RetrofitListener listener){
        Call<NoteBean> call = service.AddPic(requestBodyMap,showPic);
        bindCallback(call,listener,null,2);
    }

    public void getPicDetail(int spid,final RetrofitListener listener){
        Call<PicDeteilBean> call = service.getDetail(spid);
        bindCallback(call,listener,null,3);
    }

    public void getReview(int spid,final RetrofitListener listener){
        Call<List<ReviewBean>> call = service.getReview(spid);
        bindCallback(call,listener,null,4);
    }

    public void addReview(int uid,int spid, String conment, final RetrofitListener listener){
        Call<NoteBean> call = service.addReview(uid,spid,conment);
        bindCallback(call,listener,null,5);
    }
}
